package com.manage.platform.enums;

import lombok.Getter;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * 系统菜单权限枚举
 * 包含菜单ID、名称、路由和关联API接口
 */
@Getter
public enum MenuEnums {

    // 系统管理模块=======================================================================================================
    SYSTEM_MANAGEMENT(1000, "系统管理", "/system", 0, 1,
            new String[]{
            }
    ),

    USER_MANAGEMENT(1001, "用户管理", "/user", 1000, 1,
            new String[]{"/user/login",
                    "/user/getUserInfo",
                    "/user/resetPassword/{id}",
                    "/user/getUserPage",
                    "/user/getUserDetails/{id}",
                    "/user/saveUser",
                    "/user/updateUser",
                    "/user/deleteUser/{id}",
                    "/user/getDepartmentList",
                    "/user/getProfessionalList"
            }
    ),

    ROLE_MANAGEMENT(1002, "角色管理", "/role", 1000, 1,
            new String[]{

            }
    ),


    // 其他模块...
    ;

    private final Integer id;
    private final String menuName;
    private final String menuPath;
    private final Integer parentId;
    private final Integer menuLevel;
    private final String[] apiUrls;

    MenuEnums(Integer id, String menuName, String menuPath,
              Integer parentId, Integer menuLevel, String[] apiUrls) {
        this.id = id;
        this.menuName = menuName;
        this.menuPath = menuPath;
        this.parentId = parentId;
        this.menuLevel = menuLevel;
        this.apiUrls = apiUrls;
    }


    /**
     * 根据菜单ID获取枚举
     */
    public static MenuEnums getById(Integer id) {
        for (MenuEnums value : values()) {
            if (value.id.equals(id)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 获取所有API权限标识
     */
    public static Set<String> getAllApiPermissions() {
        Set<String> permissions = new HashSet<>();
        for (MenuEnums value : values()) {
            permissions.addAll(Arrays.asList(value.apiUrls));
        }
        return permissions;
    }


}
